/*
    Copyright (C) 2005-2008  Ricky Zheng <ricky_gz_zheng@yahoo.co.nz>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

*/
/**
 * \file uffs_config.h
 * \brief basic configuration of uffs
 * \author Ricky Zheng
 */

#ifndef _UFFS_CONFIG_H_
#define _UFFS_CONFIG_H_

#define PAGE2K 1
//#define PAGE512B 1


/**
 * \def MAX_OBJECT_HANDLE
 * maximum number of object handle
 */
#ifdef  PAGE512B
    #define EM_PAGE_BUF 512+16
    #define MAX_OBJECT_HANDLE	10
#endif

#ifdef PAGE2K
    #define EM_PAGE_BUF 2048+64
    #define MAX_OBJECT_HANDLE   50
#endif

/**
 * \def MAX_CACHED_BLOCK_INFO
 * \note uffs cache the block info for opened directories and files,
 *       a practical value is 5 ~ MAX_OBJECT_HANDLE
 */
#define MAX_CACHED_BLOCK_INFO	(MAX_OBJECT_HANDLE-1)

/**
 * \def MAX_PAGE_BUFFERS
 * \note the bigger value will bring better read/write performance.
 *       but few writing performance will be improved when this
 *       value is become larger than 'max pages per block'
 */

#ifdef PAGE512B
    #define MAX_PAGE_BUFFERS		33
#endif

#ifdef PAGE2K
    #define MAX_PAGE_BUFFERS        65
#endif

/**
 * \def MAX_DIRTY_PAGES_IN_A_BLOCK
 * \note this value should be between '2' and 'max pages per block'.
 *       the smaller the value the frequently the buffer will be flushed.
 */

#ifdef PAGE512B
    #define MAX_DIRTY_PAGES_IN_A_BLOCK 32
#endif

#ifdef PAGE2K
    #define MAX_DIRTY_PAGES_IN_A_BLOCK 64
#endif //

/** \def MAX_PATH_LENGTH */
#define MAX_PATH_LENGTH 128

/**
 * \def USE_NATIVE_MEMORY_ALLOCATOR
 * \note  the native memory allocator should only be used for
 *        tracking memory leak bugs or tracking memory consuming.
 *        In your final product, you either disable the native memory
 *        allocator or use the system heap as the memory pool for the
 *        native memory allocator.
 */
//#define USE_NATIVE_MEMORY_ALLOCATOR

/**
 * \def FLUSH_BUF_AFTER_WRITE
 * \note UFFS will write all data directly into flash in
 *       each 'write' call if you enable this option.
 *       (which means lesser data lost when power failue but lower writing performance)
 *       we recomment not open this define for normal applications.
 */
//#define FLUSH_BUF_AFTER_WRITE

/**
 * \def TREE_NODE_USE_DOUBLE_LINK
 * \note: enable double link tree node will speed up insert/delete operation,
 */
#define TREE_NODE_USE_DOUBLE_LINK


/**
 * \def MINIMUN_ERASED_BLOCK
 *  UFFS will not allow appending or creating new files when the free/erased block
 *  is lower then MINIMUN_ERASED_BLOCK.
 */
#define MINIMUN_ERASED_BLOCK 2

/**
 * \def CHANGE_MODIFY_TIME
 * If defined, closing a file which is opened for writing/appending will
 * update the file's modify time as well. Disable this feature will save a
 * lot of writing activities if you frequently open files for write and close it.
 */
#define CHANGE_MODIFY_TIME

/**
 * \def ENABLE_TAG_CHECKSUM
 */
#define ENABLE_TAG_CHECKSUM 0

//for monitor a page or spare of how many times it written.
#undef EM_MONITOR_WRITE

#endif
